package cash.cmp.personal_financial_system.service.impl;

import cash.cmp.personal_financial_system.mapper.UserMapper;
import cash.cmp.personal_financial_system.model.Role;
import cash.cmp.personal_financial_system.model.User;
import cash.cmp.personal_financial_system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User findUserById(Integer id) {

        return userMapper.findUserById(id);
    }

    public User findUserByWechat(String wechatId){
        return userMapper.findUserByWechat(wechatId);
    }

    public User findUserByAlipay(String alipayId){
        return userMapper.findUserByAlipay(alipayId);
    }

    @Override
    public Map<String, String> getUser() {
        return null;
    }

    @Override
    public List<Role> getUserRolesById(Integer id) {
        return userMapper.getUserRolesById(id);
    }

    @Override
    public User findUserByTel(String tel) {
        return userMapper.findUserByTel(tel);
    }

    @Override
    public List<User> findAllUser() {
        return userMapper.findAllUser();
    }

    @Override
    public List<User> findAllByPage(int page, int pageSize){
        int finalPage = (page - 1) * pageSize;
        return userMapper.findAllByPage(finalPage,pageSize);
    }
    @Override
    public List<User> findByAll(Integer id, String tel,Integer sex,String city ,int page, int pageSize) {
        int finalPage = (page - 1) * pageSize;
        return userMapper.findByAll(id,tel,sex,city,finalPage,pageSize);
    }

    @Override
    public List<User> findByLike(String like){
        return userMapper.findByLike(like);
    }

    @Override
    public int countByAll(Integer id, String tel, Integer sex,String city) {
        return userMapper.countByAll(id,tel,sex,city);
    }

    public int countUser(){
        return userMapper.countUser();
    }

    @Override
    public Boolean updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public Boolean updateImage(String headImage, int id){
        return userMapper.updateImage(headImage,id);
    }
    @Override
    public Boolean updateWx(String WeChatId, int id){
        return userMapper.updateWx(WeChatId,id);
    }
    @Override
    public Boolean updateApiPay(String ApiPayId, int id){
        return userMapper.updateApiPay(ApiPayId,id);
    }
    @Override
    public Boolean updateTel(String tel, int id){
        return userMapper.updateTel(tel,id);
    }

    @Override
    public Boolean deleteUser(Integer id) {
        return userMapper.deleteUser(id);
    }

    @Override
    public Boolean saveList(List<User> list) {
        return userMapper.saveList(list);
    }

}
